﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body>
    <form id="form1" name="form1" method="post" enctype="multipart/form-data">
        <div class="easyui-layout" data-options="fit:true,">
            <div data-options="region:'west',split:true,title:'用户导航'," style="padding: 1px; width: 168px; height: 100%;">
                <table id="treeview1" class="easyui-tree" data-options="title:'节点列表',method:'POST',lines:true,animate:true,dnd:true,fix:true," style="height: 100%;"></table>
            </div>
            <div data-options="region:'center'," style="padding: 1px;">
                <div class="easyui-layout" data-options="fit:true,">
                    <div data-options="region:'north',split:false,border:false," class="nowrap" style="height: 27px; overflow: hidden;">
                        <div style="float: left;">
                            <a href="javascript:void(0)" class="easyui-linkbutton mp0" id="InfoNew" data-options="iconCls:'icon-add1',plain:true,"></a>
                            <a href="#" class="easyui-menubutton" data-options="menu:'#mm2',iconCls:'icon-edit',"></a>
                            <div id="mm2" style="width: 150px;">
                                <div id="InfoView">阅读（双击）</div>
                                <div id="InfoEdit">编辑</div>
                                <div>移动</div>
                                <!--<div>剪切</div>
                                <div>复制</div>
                                <div>粘贴</div>
                                <div class="menu-sep"></div>
                                <div data-options="iconCls:'icon-undo'">撤消</div>
                                <div data-options="iconCls:'icon-redo'">恢复</div>-->
                                <div class="menu-sep"></div>
                                <div data-options="iconCls:'icon-cancel'">删除</div>
                                <div data-options="iconCls:'icon-stop'">停止</div>
                                <div class="menu-sep"></div>
                                <div id="SelectMoreNo">禁止多选</div>
                                <div id="SelectMoreYes">允许多选</div>
                                <div class="menu-sep"></div>
                                <div id="SortNo">禁止拖动排序</div>
                                <div id="SortYes">允许拖动排序</div>
                                <div class="menu-sep"></div>
                                <div id="SortSave">[本页全部] 保存顺序</div>
                                <div id="SortClear">[对选定的] 清除顺序</div>
                                <div id="SortAdd">[对选定的] 加入排序</div>
                            </div>
                        </div>
                        <div style="float: right; padding: 2px 1px 0px 2px;">
                            <input class="easyui-searchbox" data-options="prompt:'',menu:'#mmx',searcher:window.xbase.doSearch," style="width: 100px;" />
                            <div id="mmx" style="display: none;">
                                <div data-options="name:'node',plain:true,">节点</div>
                                <div data-options="name:'info',plain:true,">内容</div>
                            </div>
                        </div>
                    </div>
                    <div data-options="region:'center',border:true," style="padding: 1px; overflow: hidden;">
                        <table id="datagrid1" class="easyui-datagrid" style="width: 100%; height: 100%; overflow: hidden;" data-options="title:'新闻内容列表',iconCls:'icon-group',rownumbers:true,pagination:true,singleSelect:true,
                            method:'post',autoRowHeight:true,toolbar:'#tbs',onLoadSuccess:function(){/*$(this).datagrid('enableDnd');*/},">
                            <thead>
                                <tr>
                                    <th data-options="field:'ck',checkbox:true,"></th>
                                    <th data-options="field:'NodeId',halign:'center',">NodeId</th>
                                    <th data-options="field:'PkId',halign:'center',">PkId</th>
                                    <th data-options="field:'NodeTitle',halign:'center',">所属节点</th>
                                    <th data-options="field:'Image',halign:'center',align:'center'," style="padding-top: 2px;">默认图</th>
                                    <th data-options="field:'ImagesCount',halign:'center',align:'center',">图片数</th>
                                    <th data-options="field:'Guide',halign:'center',align:'center'," style="padding-top: 2px;">引导图</th>
                                    <th data-options="field:'Banner',halign:'center',align:'center'," style="padding-top: 2px;">宽屏图</th>
                                    <th data-options="field:'Icon',halign:'center',align:'center'," style="padding-top: 2px;">小图标</th>
                                    <th data-options="field:'Title',halign:'center',">主标题</th>
                                    <th data-options="field:'TitleSe',halign:'center',">副标题</th>
                                    <th data-options="field:'DateTimeCreate',halign:'center',formatter:window.xbase.FormatDateTime,">时间</th>
                                    <th data-options="field:'FlagStatus',halign:'center',formatter:window.xbase.FormatFlagPass,">状态</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <script type="text/javascript">
        $(function () {
            window.xbase.logonNo(); // 访问本页面，如已登录则跳转到index.html。
            $('#treeview1').tree({ url: '/Ashx/Acc/Staff/NewsAdminNodeListTree.ashx?' + window.xbase.urlparas });
            $('#treeview1').tree({
                onClick: function (node) {
                    var opts = $('#datagrid1').datagrid('getPager').data("pagination").options;
                    var q = '';
                    q += window.xbase.getQuery(q, 'id', node.attributes.value);
                    q += window.xbase.getQuery(q, 'page', opts.pageNumber);
                    q += window.xbase.getQuery(q, 'rows', opts.pageSize);
                    q += window.xbase.getQuery(q, 'rnd', Math.random());
                    q = q != '' ? '?' + q : '';
                    $('#datagrid1').datagrid({
                        url: '/Ashx/Acc/Staff/NewsAdminInfoList.ashx' + q + '&' + window.xbase.urlparas,
                        success: function (result) {
                            $.messager.alert('Access', result, 'info');
                        },
                    });
                }
            });
            $('#datagrid1').datagrid({ url: '/Ashx/Acc/Staff/NewsAdminInfoList.ashx?' + window.xbase.urlparas });
            $('#InfoView').click(function () {
                if (!window.xbase.checkDataGridItem('#datagrid1')) return;
                $('#Action').attr('value', 'ActView');
                $('#dialog1').dialog({
                    title: '内容管理·查看',
                    iconCls: 'icon-word',
                    method: 'get',
                    closed: false,
                    cache: false,
                    href: '/Html/Acc/Staff/NewsAdminInfoView.html?' + window.xbase.urlparas,
                    modal: true,
                    success: function (result) {
                        alert(result);
                    }
                });
            });
            $('#datagrid1').datagrid({
                onDblClickRow: function (index, field, value) { return false; },
                onClickRow: function (index, field, value) {
                    this.focus();
                    $('#Action').attr('value', 'ActView');
                    $('#datagrid1').datagrid('clearSelections');   //清除所有
                    $('#datagrid1').datagrid('selectRow', index);  //选择当前
                    $('#dialog1').dialog({
                        title: '详细信息',
                        iconCls: 'icon-word',
                        method: 'get',
                        closed: false,
                        cache: false,
                        href: '/Html/Acc/Staff/NewsAdminInfoView.html?' + window.xbase.urlparas,
                        modal: true,
                        success: function (result) {
                            alert(result);
                        }
                    });
                }
            });
            $('#InfoNew').click(function () {
                if (!window.xbase.checkTreeViewNode('#treeview1')) return;
                if (!window.xbase.checkTreeViewLeaf('#treeview1')) return;
                $('#Action').attr('value', 'ActNew');
                $('#dialog1').dialog({
                    title: '内容管理·新建',
                    iconCls: 'icon-word',
                    method: 'get',
                    closed: false,
                    cache: false,
                    href: '/Html/Acc/Staff/NewsAdminInfoForm.html?' + window.xbase.urlparas,
                    modal: true,
                    success: function (result) {
                        alert(result);
                    }
                });
            });
            $('#InfoEdit').click(function () {
                if (!window.xbase.checkDataGridItem('#datagrid1')) return;
                $('#Action').attr('value', 'ActEdit');
                $('#dialog1').dialog({
                    title: '内容管理·修改',
                    method: 'get',
                    closed: false,
                    cache: false,
                    href: '/Html/Acc/Staff/NewsAdminInfoForm.html?' + window.xbase.urlparas,
                    modal: true,
                    success: function (result) {
                        alert(result);
                    }
                });
            });
            $('#nodeAppend').click(function () {
                var node = $('#treeview1').tree('getSelected');
                if (node) {
                    var nodes = [
                        {
                            "id": 13, "text": "Raspberry",
                            "attributes": { "key": "/demo/book/abc", "value": 100, },
                        }, {
                            "id": 14, "text": "Cantaloupe", "attributes": { "key": "/demo/book/abc", "value": 100, },
                        }
                    ];
                    $('#treeview1').tree('append', { parent: node.target, data: nodes });
                }
            });
            $('#SelectMoreYes').click(function () { $('#datagrid1').datagrid({ singleSelect: false, }); });
            $('#SelectMoreNo').click(function () { $('#datagrid1').datagrid({ singleSelect: true, }); });
            $('#nodeRemove').click(function () {
                var node = $('#treeview1').tree('getSelected');
                $('#treeview1').tree('remove', node.target);
            });
            $('#nodeInsertBefor').click(function () {
                var node = $('#treeview1').tree('getSelected');
                if (node) {
                    $('#treeview1').tree('insert', {
                        before: node.target,
                        data: {
                            id: 21,
                            text: 'node text befor.',
                            attributes: {
                                key: "/demo/book/abc",
                                value: 100,
                            },
                        }
                    });
                }
            });
            $('#nodeInsertAfter').click(function () {
                var node = $('#treeview1').tree('getSelected');
                if (node) {
                    $('#treeview1').tree('insert', {
                        after: node.target,
                        data: {
                            id: 21,
                            text: 'node text after.',
                            attributes: {
                                key: "/demo/book/abc",
                                value: 100,
                            },
                        }
                    });
                }
            });
            $('#SortYes').click(function () {
                if (!window.xbase.checkTreeViewNode('#treeview1')) return;
                if (!window.xbase.checkTreeViewLeaf('#treeview1')) return;
                $("#datagrid1").datagrid('enableDnd');
            });
            $('#SortNo').click(function () { $("#datagrid1").datagrid('reload'); });
            $('#SortSave').click(function () {
                var opts = $('#datagrid1').datagrid('getPager').data("pagination").options;
                if (opts.pageNumber != 1) {
                    $.messager.alert("提示信息", "仅限在第1页排序。对其它页排序，可以：<br />(1)增加每页条数，使排序对象在第一页。<br />(2)选中对象，点下拉菜单“加入排序”。", 'info');
                    return;
                }
                if (!window.xbase.checkTreeViewNode('#treeview1')) return;
                if (!window.xbase.checkTreeViewLeaf('#treeview1')) return; //排序需要选中末级节点
                var rows = $('#datagrid1').datagrid("getRows");
                var arrs = new Array();
                for (var i = 0; i < rows.length; i++) arrs.push(rows[i].PkId);
                arrs.join();
                SortAction('save', arrs);
            });
            $('#SortClear').click(function () { SortSelect('clear'); });
            $('#SortAdd').click(function () { SortSelect('add'); });
            function SortSelect(act) {
                if (!window.xbase.checkDataGridItems('#datagrid1')) return;
                var rows = $('#datagrid1').datagrid("getChecked");
                var arrs = new Array();
                for (var i = 0; i < rows.length; i++)
                    arrs.push(rows[i].PkId);
                arrs.join();
                SortAction(act, arrs);
            }
            function SortAction(act, objs) {
                $('#form1').form('submit', {
                    url: '/Ashx/Acc/Staff/NewsAdminInfoListSort.ashx?act=' + act + '&rows=' + objs + '&' + window.xbase.urlparas,
                    success: function (result) {
                        if (!(result != null && result != '')) return window.xbase.return('系统错误', 'Ajax返回空值，请稍后重试！<br />ps:如果您使用了360浏览器，请换之！', 'error');
                        var json = window.xbase.json(result);
                        $.messager.alert(json.title, json.message.m_StringValue, 'info');
                        $("#datagrid1").datagrid('reload');
                    },
                });
            }
            $('#nodeUpdate').click(function () {
                var node = $('#treeview1').tree('getSelected');
                if (node) {
                    $('#treeview1').tree('update', {
                        target: node.target,
                        text: 'new text',
                        attributes: {
                            key: "/demo/book/abc",
                            value: 100,
                        },
                    });
                }
            });
        });
    </script>
</body>
</html>
